<?php

namespace think\seecms\middleware;

use Closure;

use seecms\lib\Auth;

use seecms\See;
use think\Request;
use think\response\Html;

/**
 * 中间件: 判断是否登录
 */
class AuthorizationMiddleware
{
    public function handle(Request $request, Closure $next)
    {
        $info = Auth::user()->info();

        if (empty($info)) {
            return Html::create(See::view()->fetch('user/no.login'));
        }

        // 设置用户心跳
        Auth::user()->setHeart();

        return $next($request);
    }
}